package top.hzy520.DButil;

import com.mchange.v2.c3p0.ComboPooledDataSource;

import java.beans.PropertyVetoException;
import java.sql.Connection;
import java.sql.SQLException;

public class DButil {
    public static Connection initConnection(){

        try {
            ComboPooledDataSource dataSource=new ComboPooledDataSource();
            dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/servletdemo");
            dataSource.setDriverClass("com.mysql.jdbc.Driver");
            dataSource.setUser("root");
            dataSource.setPassword("hzy947126117");
            Connection conn=  dataSource.getConnection();
            return conn;
        } catch (SQLException e) {
            e.printStackTrace();
        } catch (PropertyVetoException e) {
            e.printStackTrace();
        }
        return null;
    }
}
